package Action;

import java.util.List;

import Beans.SmsStatus;
import DAO.SmsStatusDao;
import Utils.GetHelper;

import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class SmsStatusAction extends ActionSupport {

	private int smsStatusID;
	private int parcelID;

	private SmsStatus smsStatus;

	private List<SmsStatus> smsStatues;

	SmsStatusDao smsStatusDao = new SmsStatusDao();

	/**
	 * 重发短信
	 */
	public void reSendSMS() {
		smsStatus = smsStatusDao.getSmsStatusById(smsStatusID);
		GetHelper
				.doHttpGet("http://112.124.59.126:8080/YouBoxApi/controller?funcID=0031&parcelId="
						+ smsStatus.getPackageId()+"&endMsg=(系统补发短信)");
	}

	/**
	 * 获取所有成功短信
	 */
	public String getAllSuccessSMS() {
		smsStatues = smsStatusDao.getAllSmsStatus(1);
		return "packageSMSsuccess";
	}
	/**
	 * 获取该包裹短信发送情况
	 * @return
	 */
	public String getByParcelID() {
		smsStatues = smsStatusDao.getByParcelID(parcelID);
		SmsStatus smsStatus = null;
		if(smsStatues.size()>0){
			smsStatus = smsStatues.get(0);
		}
		if(smsStatus!=null&&smsStatus.getStatus()==1){
			return "packageSMSsuccess";
		}else{
			return "packageSMSstatus";
		}
	}

	/**
	 * 获取其他状态短信
	 * 
	 * @return
	 */
	public String getAllOtherSMS() {
		smsStatues = smsStatusDao.getAllSmsStatus(0);
		return "packageSMSstatus";
	}

	public int getSmsStatusID() {
		return smsStatusID;
	}

	public void setSmsStatusID(int smsStatusID) {
		this.smsStatusID = smsStatusID;
	}

	public SmsStatus getSmsStatus() {
		return smsStatus;
	}

	public void setSmsStatus(SmsStatus smsStatus) {
		this.smsStatus = smsStatus;
	}

	public List<SmsStatus> getSmsStatues() {
		return smsStatues;
	}

	public void setSmsStatues(List<SmsStatus> smsStatues) {
		this.smsStatues = smsStatues;
	}

	public int getParcelID() {
		return parcelID;
	}

	public void setParcelID(int parcelID) {
		this.parcelID = parcelID;
	}
}
